package top.ffhome.system.service.impl;

import java.util.List;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import top.ffhome.common.audit.AuditService;
import top.ffhome.common.service.impl.BaseServiceImpl;
import top.ffhome.system.constant.SysConstants;
import top.ffhome.system.entity.SysDictData;
import top.ffhome.system.mapper.SysDictDataMapper;
import top.ffhome.system.service.SysDictDataService;

@Service
@AuditService(entity = SysDictData.class)
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictData, SysDictDataMapper>
		implements SysDictDataService {
	@Override
	@CacheEvict(value = { "dictData_selectByCategory" }, allEntries = true)
	public void clearCache() {
	}

	@Override
	@Cacheable(value = "dictData_selectByCategory", unless = "#result == null || #result.size() == 0")
	public List<SysDictData> selectByCategory(String category) {
		SysDictData dt = new SysDictData();
		dt.setCategory(category);
		dt.setStatus(SysConstants.NORMAL);
		dt.getParams().put("fields", "dd.label,dd.value,dd.clazz");
		dt.getParams().put("orderBy", "dd.sort asc");
		return mapper.select(dt);
	}
}
